package com.lsu.app.tool;

import com.huaban.analysis.jieba.JiebaSegmenter;


import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @author hjj
 * @date 2023/11/13 19:53
 */
public class jiebaUtil {
    private static JiebaSegmenter segmenter = new JiebaSegmenter();

    public static Set<String> getSignaleWord(String words) {
        Set<String> strSet = new HashSet<>();
        for (String str: segmenter.sentenceProcess(words.replaceAll("[\\pP‘’“”]", " "))) {
            if(str.length()>1){
                //贬义词提取
                if(str.contains("不")||str.contains("难")||str.contains("太")||str.contains("没")||str.contains("费")||str.contains("无")||str.contains("乱")
                        ||str.contains("过于") ||str.contains("繁琐")||str.contains("劣质")||str.contains("比较快") ||str.contains("乏味")||str.contains("比较慢")
                        ||str.contains("无帮助")||str.contains("刻板")||str.contains("低效")){
                    strSet.add(3+str);
                }else if(str.contains("好")||str.contains("益")||str.contains("简")
                        ||str.contains("易学习")||str.contains("很专业")||str.contains("兴趣")||str.contains("优质")
                        ||str.contains("丰富")||str.contains("有趣")||str.contains("互动性强")||str.contains("灵活")
                        ||str.contains("轻松")||str.contains("快捷")||str.contains("方便")||str.contains("实用")
                ){
                    strSet.add(1+str);
                }else if(str.contains("合理")||str.contains("差异")||
                        str.contains("普通")||str.contains("一般")||str.contains("还行")||str.contains("勉强")||str.contains("内容")
                        ||str.contains("答疑")||str.contains("解释")||str.contains("大纲")||str.contains("案例")||str.contains("概念")
                ){
                    strSet.add(2+str);
                }

            }
        }
        return strSet;
    }


    /**
     * 毫秒转换成hhmmss
     * @param ms 毫秒
     * @return hh:mm:ss
     */
    public static String msToss(String ms) {
        String str = "";
        long s = Long.parseLong(ms)/1000;
        int h = (int) (s/3600);
        String hh = String.valueOf(h);
        if(hh.length()==1){
            hh="0"+h;
        }
        int min = (int) ((s-h*3600)/60);
        String mins = String.valueOf(min);
        if(mins.length()==1){
            mins="0"+min;
        }
        String ss = String.valueOf(s-h*3600-min*60);
        if(ss.length()==1){
            ss="0"+ss;
        }
        str=str+hh+":"+mins+":"+ss;
        return str;
    }

}
